// Copyright 2013 Google Inc. All Rights Reserved.

#include <errno.h>

#include <irt_syscalls.h>

int dup2(int fd, int newfd) {
  ENOSYS_IF_NULL(__nacl_irt_dup2)

  int result = __nacl_irt_dup2(fd, newfd);
  if (result != 0) {
    errno = __nacl_abi_errno_to_errno(result);
    return -1;
  }
  return newfd;
}
